/*
 * Copyright ©2017 贾维程. All rights reserved.
 */
package org.handover.controller.user;

import org.handover.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.Date;

@RestController
@RequestMapping("/admin/user/")
public class UserValidate {

    @Autowired
    UserRepository userRepository;
/*
    @PostMapping("jobNumberValidate")
    public boolean jobNumberValidate(Long id, Integer jobNumber) {
        return null == id ? !userRepository.existsByJobNumber(jobNumber) : !userRepository.existsByIdNotAndJobNumber(id, jobNumber);
    }

    @PostMapping("idCardValidate")
    public boolean idCardValidate(Long id, String idCard) {
        return null == id ? !userRepository.existsByIdCard(idCard) : !userRepository.existsByIdNotAndIdCard(id, idCard);
    }

    @PostMapping("morningDateValidate")
    public boolean morningDateValidate(Long id, @DateTimeFormat(pattern = "yyyy-MM-dd") Date morningDate) {
        return null == id ? !userRepository.existsByMorningDate(morningDate) : !userRepository.existsByIdNotAndMorningDate(id, morningDate);
    }
    */
}
